package cn.com.duiba.millionaire.center.spider.common;

import com.google.common.collect.Lists;
import us.codecraft.webmagic.Page;

import java.util.List;
import java.util.Random;

@FunctionalInterface
public interface PageConsumer {

    void accept(Page page);

    default void spiderSleep(){
        //随机休眠一会，再继续爬取
        List<String> delayTime = Lists.newArrayList("1000","2000","3000");
        int i = new Random().nextInt(delayTime.size());
        try {
            Thread.sleep(Integer.valueOf(delayTime.get(i)));
        } catch (Exception var3) {
            throw new RuntimeException("sleep fail,{}", var3);
        }
    }
}